Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate Embedded ObjectMeta in the CRDs #4315

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

zhzhuang-zju
Copy link
Contributor

@zhzhuang-zju zhzhuang-zju commented Nov 24, 2023

What type of PR is this?
/kind bug

What this PR does / why we need it:
generate Embedded ObjectMeta in the CRDs
Which issue(s) this PR fixes:
Fixes #4128

Special notes for your reviewer:
none
Does this PR introduce a user-facing change?:

`karmada-operator`: Enable embedded object meta generated for karmada operator CRD.

@karmada-bot karmada-bot added the kind/bug Categorizes issue or PR as related to a bug. label Nov 24, 2023
@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 24, 2023
@zhzhuang-zju
Copy link
Contributor Author

Verification report

  • generate Embedded ObjectMeta in the CRDs with new update-crdgen.sh
  • kubectl apply -f operator/config/crds/operator.karmada.io_karmadas.yaml
➜  karmada git:(master) ✗ kubectl apply -f operator/config/crds/operator.karmada.io_karmadas.yaml 
customresourcedefinition.apiextensions.k8s.io/karmadas.operator.karmada.io configured
  • kubectl apply -f operator/config/samples/karmada.yaml
➜  karmada git:(master) ✗ kubectl apply -f operator/config/samples/karmada.yaml 
karmada.operator.karmada.io/karmada-demo configured

@codecov-commenter
Copy link

codecov-commenter commented Nov 24, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (cf1dbf0) 51.99% compared to head (798f916) 51.89%.
Report is 105 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4315      +/-   ##
==========================================
- Coverage   51.99%   51.89%   -0.11%     
==========================================
  Files         242      243       +1     
  Lines       23977    24150     +173     
==========================================
+ Hits        12468    12532      +64     
- Misses      10829    10935     +106     
- Partials      680      683       +3     
Flag Coverage Δ
unittests 51.89% <ø> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@chaunceyjiang
Copy link
Member

/assign

@chaunceyjiang
Copy link
Member

Can you help test the situation where both namespace and name are numbers? For example, name = 123, namespace=123. @zhzhuang-zju

@zhzhuang-zju
Copy link
Contributor Author

Can you help test the situation where both namespace and name are numbers? For example, name = 123, namespace=123. @zhzhuang-zju

Do you mean namepace and name of the embedded objectMeta?

@zhzhuang-zju
Copy link
Contributor Author

Can you help test the situation where both namespace and name are numbers? For example, name = 123, namespace=123. @zhzhuang-zju

I tested it according to your request and the results are as follows.

  1. set both namespace and name to 123, and it failed for invalid value.
➜  karmada git:(master) ✗ kubectl apply -f operator/config/samples/karmada.yaml 
The Karmada "karmada-demo" is invalid: 
* spec.components.etcd.local.volumeData.volumeClaim.metadata.namespace: Invalid value: "integer": spec.components.etcd.local.volumeData.volumeClaim.metadata.namespace in body must be of type string: "integer"
* spec.components.etcd.local.volumeData.volumeClaim.metadata.name: Invalid value: "integer": spec.components.etcd.local.volumeData.volumeClaim.metadata.name in body must be of type string: "integer"
  1. set both namespace and name to "123", and it succeed
➜  karmada git:(master) ✗ kubectl apply -f operator/config/samples/karmada.yaml
karmada.operator.karmada.io/karmada-demo created

@zhzhuang-zju
Copy link
Contributor Author

cc @chaunceyjiang

@chaunceyjiang
Copy link
Member

set both namespace and name to 123, and it failed for invalid value.

This is exactly the issue I encountered. It seems that your PR did not solve this issue, right?

@zhzhuang-zju
Copy link
Contributor Author

set both namespace and name to 123, and it failed for invalid value.

This is exactly the issue I encountered. It seems that your PR did not solve this issue, right?

Do you mean that you want to set name or namespace a int value?

@zhzhuang-zju
Copy link
Contributor Author

set both namespace and name to 123, and it failed for invalid value.

This is exactly the issue I encountered. It seems that your PR did not solve this issue, right?

@chaunceyjiang Hi~ referring to your issue #4332, what you expect is to set the namespace and name to "123", if so, this PR solves the problem, you can refer to #4315 (comment) for the second scenario.

Signed-off-by: zhzhuang-zju <m17799853869@163.com>
@karmada-bot karmada-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 13, 2023
Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

The root cause is that controller-gen skips embedded metada when generating CRDs.

as per: https://book.kubebuilder.io/reference/controller-gen.html?highlight=generateEmbeddedObjectMeta#generators

generateEmbeddedObjectMetabool
specifies if any embedded ObjectMeta in the CRD should be generated

PS:

VolumeClaim *corev1.PersistentVolumeClaimTemplate `json:"volumeClaim,omitempty"`

The corev1.PersistentVolumeClaimTemplate includes metadata definition.

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Dec 13, 2023
@RainbowMango
Copy link
Member

@chaunceyjiang Would you like to take another look?

Copy link
Member

@chaunceyjiang chaunceyjiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks~

/lgtm

@RainbowMango
Copy link
Member

/approve

@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RainbowMango

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@karmada-bot karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 13, 2023
@karmada-bot karmada-bot merged commit a777c3a into karmada-io:master Dec 13, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

operator/config/samples/karmada.yaml may be not valid
5 participants